﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace YagnaColor
{
    /// <summary>
    /// Interaction logic for GradientSelector.xaml
    /// </summary>
    public partial class GradientSelector : UserControl
    {
        public static readonly DependencyProperty SelectedBrushProperty = DependencyProperty.Register("SelectedBrush", typeof(GradientBrush), typeof(GradientSelector), new PropertyMetadata(null));

        public GradientBrush SelectedBrush
        {
            get { return (GradientBrush)GetValue(SelectedBrushProperty); }
            set { SetValue(SelectedBrushProperty, value); }
        }

        public GradientSelector()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            if (GradientControl.SelectedBrushType == YagnaColor.GradientControl.GradientBrushType.Linear)
                SetValue(SelectedBrushProperty, GradientControl.SelectedLinearBrush);
            else if(GradientControl.SelectedBrushType == YagnaColor.GradientControl.GradientBrushType.Radial)
                SetValue(SelectedBrushProperty, GradientControl.SelectedRadialBrush);
            Window win = Window.GetWindow(GradientBrushControl) as Window;
            if (win != null)
                win.Close();
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            Window win = Window.GetWindow(GradientBrushControl) as Window;
            if (win != null)
                win.Close();
        }
    }
}
